﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Zj.HttpCodeDemo.App.Tag.Events;
using Zj.HttpCodeDemo.Domain.Entities;
using Zj.HttpCodeDemo.Domain.Events;

namespace Zj.HttpCodeDemo.Mvc.Controllers
{
    public class UsersController : Controller
    {
        private readonly IEventBus _eventBus;
        public UsersController(IEventBus eventBus)
        {
            this._eventBus = eventBus;
        }
        // GET: Users
        public ActionResult Index()
        {
            return View();
        }


        public ActionResult Create(string name,string pwd)
        {
            var user = new User() { UserName="ZhangWen", Pwd="p@ssw0rd" };
            this._eventBus.PublishAsync(new UserCreatedEvent() {  UserName=name, Pwd=pwd,TimeStamp=DateTime.Now});
            return View("Index");
        }
    }
}